<?php

$options = Config::getInstance()->cache_frontend_page;
$options = $options->toArray();

if (!$options['enable'] || Debug::getInstance()->isDebugMode()) {
	return ;
}

	// Redirect to mobile version when we trying access page with phone.
	// Copypaste from IndexController for redirect when cache enabled.
	require_once (BASE_DIR . '/wurfl/tera_wurfl.php');
	$wurflObj = new tera_wurfl();
	$matched = $wurflObj->getDeviceCapabilitiesFromAgent($_SERVER['HTTP_USER_AGENT']);
	if ($matched && $wurflObj->getDeviceCapability("is_wireless_device")) {
		header('Location: http://' . Config::getInstance()->default->waphostname);
	}

foreach ($options['rules'] as $rule) {
	$options['regexps'][$rule] = array('cache' => true);
}

Zend_Session::start();
$frontend = new Zend_Cache_Frontend_Page($options);
$backend = Cache_Manager::getInstance()->getCleanBackend();
//$backend = new Zend_Cache_Backend_File(array('cache_dir' => BASE_DIR . '/tmp/cache/'));
$frontend->setBackend($backend);

$frontend->start();
